//先导入一些必须的东西
import {
    DepartmentItem,
    DepartmentFormData,
  } from '@/types';
  import request from '@/utils/request';
  import { AxiosPromise } from 'axios';

/**
 * 获取部门列表
 *
 * 
 */
 export function listDepartment(
  ): AxiosPromise<DepartmentItem[]> {
    return request({
      url: '/department?action=list',
      method: 'get',
    });
  }

// /**
//  * 获取部门列表
//  *
//  * 
//  */
//  export function listDepartment(specificAction:string
//   ): AxiosPromise<DepartmentItem[]> {
//     return request({
//       url: '/department?action=' + specificAction,
//       method: 'get',
//     });
//   }

  /**
 * 获取部门详情
 *
 * @param id
 */
export function getDepartmenFormDetail(id: number): AxiosPromise<DepartmentFormData> {
  return request({
    url: '/department?action=detail&id=' + id,
    method: 'get',
  });
}

  /**
 * 添加部门
 *
 * @param data
 */
export function addDepartmen(data: DepartmentFormData) {
  console.log(data)
  return request({
    url: '/department',
    method: 'post',
    data: data,
  });
}

  /**
 * 修改部门
 *
 * @param id
 * @param data
 */
export function updateDepartmen(id: number, data: DepartmentFormData) {
  return request({
    url: '/department',
    method: 'put',
    data: data,
  });
}
  /**
 * 删除部门
 *
 * @param ids
 */
export function deleteDepartmen(ids: string) {
  return request({
    url: '/department?id=' + ids,
    method: 'delete',
  });
}


